//登陆接口
define(function(require, exports, module) {
  const fetch=require('fetch');
  module.exports={
      //获取jssdk参数
      getJsConfig:function (url) {
          return fetch({
              baseURL:'/mobile',
              url:'/getJsSign?url='+url,
              method:'post'
          });
      },
      //发送授权code
      authCode:function (code,state,openid) {
          openid=openid||'';
          return fetch({
              baseURL:'/mobile',
              url:'/login?code='+code+"&state="+state+"&openId="+openid,
              method:'post'
          });
      },
      //获取验证码
      getCode:function (phone,openid) {
          openid=openid||'';
          return fetch({
              method:'post',
              data:{
                  "user_get_code":
                      {
                          "vendor_id":"QHYS",
                          "device_flag":"USER",
                          "mobile_phone":phone,
                          "send_type":"0",   // 0表示短信 1表示语音
                          "user_role":"1",   //1表示用车用户0表示运维用户
                          "user_id":"0",      // 如果是用户登录， 则user_id 等于0，  如果是 1绑定银行卡或 2用户更换手机号， 则上传对应的 用户id值
                          "sms_purpose":"0", //短信用途0用户登录1绑定银行卡 2用户更换手机号
                          "open_id":openid
                      }
              }
          });
      },
      //登陆
      /* 验证码接口返回数据：
      *{"user_get_code":
      * {"vendor_id":"QHYS","device_flag":"SERVER","return_code":"SUCCESS","return_msg":"","mobile_phone":"18812345678","user_role":"1","user_id":26
      * }}
      * */
      login:function (verification_code,invite_code,user_get_code) {
          return fetch({
              method:'post',
              data:{
                  "user_login":
                      {
                          "vendor_id":user_get_code.vendor_id,
                          "device_flag":user_get_code.device_flag,
                          "verification_code":verification_code,
                          "user_role":user_get_code.user_role,
                          "user_id":user_get_code.user_id,
                          "invite_code":invite_code||'',
                          "mobile_phone":user_get_code.mobile_phone
                      }
              }
          });
      },
      loginOut:function (user_info) {
        return fetch({
            method:"post",
            data:{
                "user_logout":
                    {
                        "vendor_id":user_info.vendor_id,
                        "device_flag":user_info.device_flag,
                        "token":user_info.token,
                        "user_role":user_info.user_role,
                        "user_id":user_info.user_id,
                        "mobile_phone":user_info.mobile_phone
                    }
            }
        });
      },
      //获取用户信息
      getUserInfo:function (user_info) {
          return fetch({
              method:'post',
              data:{
                  "user_get_info":
                      {
                          "vendor_id":user_info.vendor_id,
                          "device_flag":user_info.device_flag,
                          "token":user_info.token,
                          "user_role":user_info.user_role,
                          "user_id":user_info.user_id,
                          "mobile_phone":user_info.mobile_phone
                      }
              }
          });
      },
      //身份认证
      postCertification:function (name,code,user_info) {
          return fetch({
              method:'post',
              data:{
                  "user_certification":
                      {
                          "user_name":name,
                          "user_code":code,
                          "vendor_id":user_info.vendor_id,
                          "device_flag":user_info.device_flag,
                          "token":user_info.token,
                          "user_role":user_info.user_role,
                          "user_id":user_info.user_id,
                          "mobile_phone":user_info.mobile_phone
                      }
              }
          });
      },
      //get充值金额
      getChargePresent:function (user_info) {
          return fetch({
              method:'post',
              data:{
                  "get_charge_present": {
                      "vendor_id": user_info.vendor_id,
                      "device_flag": user_info.device_flag,
                      "token": user_info.token,
                      "user_role": user_info.user_role,
                      "user_id": user_info.user_id,
                      "mobile_phone": user_info.mobile_phone,
                  }
              }
          });
      },
      //get押金
      getChargeDeposit:function (user_info) {
          return fetch({
              method:'post',
              data:{
                  "get_deposit_amount": {
                      "vendor_id": user_info.vendor_id,
                      "device_flag": user_info.device_flag,
                      "token": user_info.token,
                      "user_role": user_info.user_role,
                      "user_id": user_info.user_id,
                      "mobile_phone": user_info.mobile_phone,
                      "deposit_type": "0" //0 用车押金 1 电池押金
                  }
              }
          });
      },
      //押金充值
      chargeDeposit:function (charge_deposit,charge_amount,present_amount,openid,user_info) {
          return fetch({
              method:'post',
              data:{
                  "user_charge_deposit":
                      {
                          "vendor_id":user_info.vendor_id,
                          "device_flag":user_info.device_flag,
                          "token":user_info.token,
                          "user_role":user_info.user_role,
                          "user_id":user_info.user_id,
                          "mobile_phone":user_info.mobile_phone,
                          "charge_deposit":charge_deposit,  //1表示充押金 0表示充值 2 表示充运维押金 3 表示领养押金
                          "charge_amount":charge_amount,    //充值金额 10/20/50/100 单位元
                          "present_amount":present_amount,     //赠送金额
                          "battery_count":"",        //电池个数
                          "adoption_cycle":"" ,      //领养时间 1个月、 3个月、 6个月、 12个月
                          "bike_code":"",   //领养的单车二维码编号
                          "charge_type":"1",   //0表示支付宝 1表示微信 2表示银行卡 3钱包支付
                          "client_host":"" ,   //用户端实际ip
                          "open_id":openid||''
                      }
              }
          });
      },
      //充值成功回调
      chargeDespositStatus:function (prepayid,charge_status,desc,user_info) {
          return fetch({
              method:'post',
              data: {
                  "user_report_charge_status": {
                      "vendor_id":user_info.vendor_id,
                      "device_flag":user_info.device_flag,
                      "token":user_info.token,
                      "user_role":user_info.user_role,
                      "user_id":user_info.user_id,
                      "mobile_phone":user_info.mobile_phone,
                      "adopt_seriNo": prepayid,  //订单号
                      "charge_result": charge_status, //返回信息，0 失败，1 成功
                      "charge_desc":desc
                  }
              }
          });
      },
      //用户信用分记录
      creditInfo:function (page,size,user_info) {
          return fetch({
              method:"post",
              data:{
                  "user_credit_info":
                      {
                          "vendor_id":user_info.vendor_id,
                          "device_flag":user_info.device_flag,
                          "token":user_info.token,
                          "user_role":user_info.user_role,
                          "user_id":user_info.user_id,
                          "mobile_phone":user_info.mobile_phone,
                          "current_page":page||1,
                          "page_number":size||20
                      }
              }
          });
      },
      //交易明细
      chargeInfo:function (page,size,amount_type,is_income,user_info) {
          return fetch({
              method:"post",
              data:{
                  "user_charge_info":
                      {
                          "vendor_id":user_info.vendor_id,
                          "device_flag":user_info.device_flag,
                          "token":user_info.token,
                          "user_role":user_info.user_role,
                          "user_id":user_info.user_id,
                          "mobile_phone":user_info.mobile_phone,
                          "current_page":page||1,
                          "page_number":size||20,
                          "amount_type":amount_type,	  //类型：0钱包金额  1 赠送金额
                          "is_income":is_income      // 1 收入  0 支出
                      }
              }
          });
      },
      //单车解锁
      useBike:function (mode,code,openid,user_info) {
          return fetch({
              method:'post',
              timeout:60000,
              data:{
                  "user_use_bike":
                  {
                      "bike_code":code,   //单车二维码编号
                      "vendor_id":user_info.vendor_id,
                      "device_flag":user_info.device_flag,
                      "token":user_info.token,
                      "user_role":user_info.user_role,
                      "user_id":user_info.user_id,
                      "mobile_phone":user_info.mobile_phone,
                      "unlock_mode":mode||0+"",   //0 扫码开锁 1 输入编码开锁
                      "open_id":openid||''
                  }
              }
          });
      },
      //用车状态
      useBikeStatus:function (code,unlock_time,user_info) {
          return fetch({
                  method:'post',
                  data:{
                      "query_user_use_bike_status":
                          {
                              "bike_code":code,   //单车二维码编号
                              "unlock_time":unlock_time,            //使用开始时间 (开锁时间)
                              "vendor_id":user_info.vendor_id,
                              "device_flag":user_info.device_flag,
                              "token":user_info.token,
                              "user_role":user_info.user_role,
                              "user_id":user_info.user_id,
                              "mobile_phone":user_info.mobile_phone,
                          }
                  }
          });
      },
      //获取用户行程信息
      useBikeInfo:function (page,size,user_info) {
          return fetch({
              method:'post',
              data:{
                  "user_use_bike_info":
                  {
                      "current_page":page+"",   	//APP当前请求显示页
                      "page_number":size+"",			//APP 页最大显示记录数
                      "vendor_id":user_info.vendor_id,
                      "device_flag":user_info.device_flag,
                      "token":user_info.token,
                      "user_role":user_info.user_role,
                      "user_id":user_info.user_id,
                      "mobile_phone":user_info.mobile_phone,
                  }
              }
          });
      }
  };
});
